window.addEventListener('load',function(){
	var regtel = /^1[3|4|5|6|7|8|9]\d{9}$/; // 正则表达式
	var regyz = /^\d{4}$/;
	var regps = /^[a-zA-Z0-9._-]{8,16}$/;
	var regqq = /^\d{6,13}$/; 
	var tel = document.querySelector('#tel');
	var yanz = document.querySelector('#yanz');
	var passwold = document.querySelector('#password');
	var surepwd = document.querySelector('#surepwd');
	regexp(tel,regtel);
	regexp(yanz,regyz);
	regexp(passwold,regps);
	function regexp(ele,reg) {
		ele.addEventListener('blur',function() {
			console.log(this);
			if(reg.test(this.value)) {
				this.nextElementSibling.className = 'success';
				this.nextElementSibling.innerHTML = '<i class="error_icon"></i> 输入正确';
			} else {
				this.nextElementSibling.className = 'error';
				this.nextElementSibling.innerHTML = '<i class="error_icon"></i> 格式不正确，请重新输入';
				
			}
		});
	}
	
	surepwd.addEventListener('blur',function() {
		if(this.value == passwold.value) {
			this.nextElementSibling.className = 'success';
			this.nextElementSibling.innerHTML = '<i class="error_icon"></i> 输入正确';
		} else {
			this.nextElementSibling.className = 'error';
			this.nextElementSibling.innerHTML = '<i class="error_icon"></i> 输入密码不一致';
		}
	})
})